package com.yzc.config;

import com.yzc.util.JwtUtil;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WebConfig {
    @Bean
    public FilterRegistrationBean<MdcFilter> mdcFilter(JwtUtil jwtUtil) {
        FilterRegistrationBean<MdcFilter> registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(new MdcFilter(jwtUtil)); // 通过构造函数注入
        registrationBean.addUrlPatterns("/*"); // 设置过滤的 URL 模式
        return registrationBean;
    }
}
